import logging
import datetime
import sys

# ----------------------------------------------------------------------------
# --- 2. 日志和种子辅助函数 (Logging & Seed Helpers) ---
# ----------------------------------------------------------------------------
# --- 日志配置 ---
now = datetime.datetime.now()
timestamp = now.strftime("%Y%m%d_%H%M")


# 在 main() 中调用
def setup_logging(log_name: str = "base"):
    """配置日志记录器"""

    log_file_path = f"logs/{timestamp}_{log_name}.log"
    logging.getLogger().handlers = []
    logging.basicConfig(
        level=logging.INFO,
        format="%(asctime)s - %(levelname)s - %(message)s",
        datefmt="%Y-%m-%d %H:%M:%S",
        handlers=[
            logging.FileHandler(log_file_path, mode="w"),
            logging.StreamHandler(sys.stdout),
        ],
    )
    logger = logging.getLogger()
    logger.info(f"日志系统已启动。日志将保存到: {log_file_path}")
    return logger,log_file_path
